package com.r2coding.music.listener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.r2coding.music.ExcelSongModel;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

/**
 * @author:98k灬
 * @since:2022/05/10 12:13
 **/
public class SongListener extends AnalysisEventListener<ExcelSongModel> {

    @Getter
    private List<ExcelSongModel> list = new ArrayList<ExcelSongModel>();

    public SongListener() {
        super();
        list.clear();
    }

    // 每一条数据都会解析
    @Override
    public void invoke(ExcelSongModel songModel, AnalysisContext analysisContext) {
        list.add(songModel);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
        list.forEach(System.out::println);
    }
}
